package com.pb.wkflow.api.controller.assembler;

import com.pb.infra.oth.util.UserInfo;
import com.pb.wkflow.api.controller.assembler.mapper.ClassifyDtoMapper;
import com.pb.wkflow.api.controller.request.ClassifyQueryRequest;
import com.pb.wkflow.api.entity.WfSysClassifyEntity;

/**
 * 流程分类 ClassifyAssembler
 * @author 苗益辉
 * @date 2022/9/8 10:45
 */
public class ClassifyAssembler {

    private ClassifyAssembler() {

    }

    /**
     * 查询
     * @param request request
     * @param userInfo userInfo
     * @return WfSysClassifyEntity
     */
    public static WfSysClassifyEntity assemblerToQuery(ClassifyQueryRequest request, UserInfo userInfo) {
        return ClassifyDtoMapper.INSTANCE.assemblerToQuery(request, userInfo);
    }

    /**
     * 保存
     * @param request request
     * @param userInfo UserInfo
     * @return WfSysClassifyEntity
     */
    public static WfSysClassifyEntity assemblerToSave(ClassifyQueryRequest request, UserInfo userInfo) {
        WfSysClassifyEntity entity = ClassifyDtoMapper.INSTANCE.assemblerToSave(request, userInfo);
        if (request.getIsAble() == null) {
            entity.setIsAble(1);
        } else {
            entity.setIsAble(request.getIsAble());
        }
        return entity;
    }

    /**
     * 修改
     * @param request 新数据
     * @param entity 原数据
     * @return WfSysClassifyEntity
     */
    public static WfSysClassifyEntity assemblerToUpdate(ClassifyQueryRequest request, WfSysClassifyEntity entity) {
        ClassifyDtoMapper.INSTANCE.assemblerToUpdate(request, entity);
        return entity;
    }
}
